package com.ibangnuo.manage.controller.system;

import com.ibangnuo.api.system.SysConfigControllerApi;
import com.ibangnuo.framework.domain.system.SysConfig;
import com.ibangnuo.framework.model.response.ObjectResult;
import com.ibangnuo.framework.model.response.QueryResponseResult;
import com.ibangnuo.framework.model.response.ResponseResult;
import com.ibangnuo.manage.service.system.SySConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: wwy
 * @Date: 2019-12-21 14:24
 */
@RestController
@RequestMapping("/system/config")
public class SysConfigController implements SysConfigControllerApi {
    @Autowired
    private SySConfigService sySConfigService;

    /**
     * 根据type查找
     * @param type
     * @return
     */
    @GetMapping("/findByType/{type}/{snNum}")
    @Override
    public ObjectResult findByType(@PathVariable("type") String type,@PathVariable("snNum") String snNum) {
        return sySConfigService.findByType(type,snNum);
    }

    /**
     * 添加
     * @param sysConfig
     * @return
     */
    @PostMapping("/add")
    @Override
    public ResponseResult add(@RequestBody SysConfig sysConfig) {
        return sySConfigService.add(sysConfig);
    }

    /**
     * 根据id更新
     * @param id
     * @param sysConfig
     * @return
     */
    @PostMapping("/update/{id}")
    @Override
    public ResponseResult update(@PathVariable("id") String id, @RequestBody SysConfig sysConfig) {
        return sySConfigService.update(id,sysConfig);
    }

    /**
     * 根据id删除
     * @param id
     * @return
     */
    @DeleteMapping("/delete/{id}")
    @Override
    public ResponseResult delete(@PathVariable("id") String id) {
        return sySConfigService.delete(id);
    }

    /**
     * 查询全部
     * @return
     */
    @GetMapping("/list")
    @Override
    public QueryResponseResult findAll() {
        return sySConfigService.findAll();
    }
}
